upload a pdf file laravel

40

$pdf = PDF::loadView('pdf.invoice', $data);

Storage::put('public/pdf/invoice.pdf', $pdf->output());

return $pdf->download('invoice.pdf');
class FileController extends Controller
{
    // ...

    public function upload(Request $request)
    {
        $uniqueFileName = uniqid() . $request->get('upload_file')->getClientOriginalName() . '.' . $request->get('upload_file')->getClientOriginalExtension());

        $request->get('upload_file')->move(public_path('files') . $uniqueFileName);

        return redirect()->back()->with('success', 'File uploaded successfully.');
    }

    // ...
}

Comments

Submit
0 Comments